<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8"></meta>
		<title>layui</title>
		<meta name="renderer" content="webkit"></meta>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></meta>
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"></meta>
		<link rel="stylesheet" href="layui/css/layui.css" media="all"></link>
	</head>
	<body>
	<style>
	img{
	width:50px;
	lheight:50px;
	}
	</style>
	
	
	
	
 <script src="layui/layui.js"></script>
 
 
 
  <div class="demoTable">
  搜索ID：
  <div class="layui-inline">
    <input class="layui-input" name="id" id="demoReload" autocomplete="off">
  </div>
  <button class="layui-btn" data-type="reload">搜索</button>
</div>
		<table class="layui-table" id="demo" lay-filter="demo"></table>
		 
	
		<script type="text/html" id="barDemo">
		 
			<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
<a class="layui-btn layui-btn-xs" lay-event="look">查看</a>
		</script>
		<div id="idcard" style="display: none; height:100px">
  <table class="layui-table" id="exameeinfo" lay-filter="exameeinfo"   align="center"></table>
		</div>
		<script src="layui/layui.js"></script> 
		<script src="js/jquery-3.3.1.min.js"></script>
 <script>

 layui.use('table', function() {
		var table = layui.table,
			form = layui.form;
	
		 var $ = layui.$, active = {
				    reload: function(){
				      var demoReload = $('#demoReload');
				      alert(demoReload.val());
				      //执行重载
				      table.reload('testReload', {
				        page: {
				          curr: 1 //重新从第 1 页开始
				        }
				        ,where: {
				          key: {
				            id: demoReload.val()
				          }
				        }
				      });
				    }
				  };
	
			tableIns=table.render({
				elem: '#demo',
				url: 'examineeinfo',
				id: 'testReload',
				page:true,
				width:"100%",
				cols: [
					[  
						{
							field: 'id',
							title: 'ID',
							width: 80,
							sort: true,
							fixed: true
						},
						{
							field: 'idNumber',
							title: '身份证',
							width: 100
						},
						{
							field: 'qenumber',
							title: '准考证',
							width: 100
						},
						{
							field: 'examinationInformationID',
							title: '考试名称',
							width: 200
						}, {
							field: 'paymentState',
							title: '支付状态',
							width: 200,
							sort: true
						}, {
							field: 'testSite',
							title: '考试地点',
							width: 100
						},{
							field: 'right',
							width: 178,
							align: 'center',
							toolbar: '#barDemo'
						}
					]
				],
				done: function(res, curr, count){
    				
     pageCurr=curr;
 }
			});
		/*}*/

		//监听工具条

		table.on('tool(demo)', function(obj) {

			var data = obj.data;
			if(obj.event==='look')
				{
				
				
				
				 layui.use('table', function() {
					 
						var table = layui.table,
							form = layui.form;
							//监听单元格编辑
							tableIns=table.render({
								elem: '#exameeinfo',
								url:'examineeinfobyidnum?idnum='+data.idNumber //数据接口
								,
								id: 'idTest',
								 
								cellMinWidth: 80,
								cols: [
									[ 
										{
											field: 'uName',
											title: '姓名',
									 
											sort: true,
											fixed: true
										},
										{
											field: 'uIdnumber',
											title: '身份证' 
									 
										},
										{
											field: 'qNumber',
											title: '准考证'  
										},
										{
											field: 'tName',
											title: '考试名称' 
										},
										{
											field: 'tSite',
											title: '考试地点' 
										},
										{
											field: 'tTime',
											title: '时间' 
										},{
											field: 'right',
											 
											align: 'center',
											toolbar: '#barexameeinfo'
										}
									]
								],
								done: function(res, curr, count){
				    				
				     pageCurr=curr;
				 }
							});
							 
				})
				layer.open({
					type: 1,
					title: "准考证",
					fixed: false,
					resize: false,
					shadeClose: true,
					area: ['100%'],
			 
					content: $('#idcard')
				});
				}
			  if(obj.event === 'del') {
				layer.confirm('真的删除行么', function(index) {
					
					$.get("delexamineeinfo", {
						"id": data.id
					}, function(data) {
						if(data.code == "1000") {
							layer.msg("删除成功");
				 
						}
						else
							{
							layer.msg("出错了");
							 
							}
					});
					  obj.del();
				      layer.close(index);
				});
			}  
		});
		
	  	$('.demoTable .layui-btn').on('click', function() {
			var type = $(this).data('type');
			active[type] ? active[type].call(this) : '';
		});  
		
		form.on('submit(editSubmit)', function(data) {
			formSubmit(data);
			return false;
		});
	});
   
	 
function load(obj){
//重新加载table
tableIns.reload({
where: obj.field
, page: {
 curr: pageCurr //从当前页码开始
}
});
} 

 
	 
 </script>
 
	</body>
</html>